package com.csii.activiti.server.api;

import com.csii.activiti.server.abstraction.entity.ActDept;
import com.csii.activiti.server.abstraction.entity.ActRole;
import com.csii.activiti.server.abstraction.entity.ActUser;
import com.csii.activiti.server.abstraction.service.ActDeptService;
import com.csii.activiti.server.abstraction.service.ActRoleService;
import com.csii.activiti.server.abstraction.service.ActUserService;
import com.csii.activiti.server.api.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags="基本接口")
@RestController
@RequestMapping("/${activity.basic.url:activiti}/basic")
public class BasicController {

    @Autowired
    private ActUserService actUserService;

    @Autowired
    private ActRoleService actRoleService;

    @Autowired
    private ActDeptService actDeptService;


    @ApiOperation("根据账户和昵称模糊搜索用户")
    @GetMapping("/queryUserLikeUsernameOrNickname")
    public Result<List<ActUser>> queryUserLikeUsernameOrNickname(@ApiParam(value = "昵称或者username" ,required = true) @RequestParam String usernameOrNickname){
        return Result.ok(actUserService.queryUserLikeUsernameOrNickname(usernameOrNickname));
    }

    @ApiOperation("根据角色名称模糊搜索角色")
    @GetMapping("/queryRoleLikeRoleName")
    public Result<List<ActRole>> queryRoleLikeRoleName(@ApiParam(value = "角色名称" ,required = true) @RequestParam String roleName){
        return Result.ok(actRoleService.queryRoleLikeRoleName(roleName));
    }

    @ApiOperation("根据部门名称模糊搜索部门")
    @GetMapping("/queryDeptLikeDeptName")
    public Result<List<ActDept>> queryDeptLikeDeptName(@ApiParam(value = "角色名称" ,required = true) @RequestParam String deptName){
        return Result.ok(actDeptService.queryDeptLikeDeptName(deptName));
    }

}
